
// js 是需要自己设置导入导出的
export default[
    {
        path:"/",
        redirect:"/home",
        meta:{
            isShowFooter: true
        }
    },
    {
        path: '/home',
        name: 'home',
        component: () => import('@/pages/Home/index.vue'),
        meta:{
            isShowFooter: true
        }
    },
    {
        path:"/search/:keyword?",
        name:"search",
        component: () => import('@/pages/Search'),
        meta:{
            isShowFooter: true
        }
    },
    {
        name: 'detail', 
        path: '/detail/:skuId',
        component: () => import('@/pages/Detail'),
        meta:{
            isShowFooter: false
        }
    },
    {
        path: '/addcartsuccess',
        name:"addcartsuccess",
        component:() => import('@/pages/AddCartSuccess'),
        meta:{
            isShowFooter: true
        }
    },
    {
        path:"/shopcart",
        component:() => import('@/pages/ShopCart'),
        meta:{
            isShowFooter: true
        }
    },
    {
        path: '/register',
        component: () => import('@/pages/Register'),
        meta: {
          isHideFooter: true
        }
      },
      {
        path: '/login',
        component: () => import('@/pages/Login'),
        meta: {
          isHideFooter: true
        }
      },
      {
        path: '/trade',
        component: () => import('@/pages/Trade'),
        /* 只能从购物车界面, 才能跳转到交易界面 */
        beforeEnter (to, from, next) {
          if (from.path==='/shopcart') {
            next()
          } else {
            next('/shopcart')
          }
        }
      },
      {
        path: '/pay',
        component: () => import('@/pages/Pay'),
    
        // 将query参数映射成props传递给路由组件
        props: route => ({orderId: route.query.orderId}),
    
        /* 只能从交易界面, 才能跳转到支付界面 */
        beforeEnter (to, from, next) {
          if (from.path==='/trade') {
            next()
          } else {
            next('/trade')
          }
        }
      },
      
      {
        path: '/paysuccess',
        component: () => import('@/pages/PaySuccess'),
        /* 只有从支付界面, 才能跳转到支付成功的界面 */
        beforeEnter (to, from, next) {
          if (from.path==='/pay') {
            next()
          } else {
            next('/pay')
          }
        }
      },
      {
        path: '/center',
        component: () => import('@/pages/Center'),
        children: [
          {
            // path: '/center/myorder',
            path: 'myorder',
            component: () => import('@/pages/Center/myOrder'),
          },
          {
            path: 'grouporder',
            component: () => import('@/pages/Center/groupOrder'),
          },
    
          {
            path: '',
            redirect: 'myorder'
          }
        ]
      },  
      {
        path:"/test",
        component: () => import('@/pages/Test'),
      }  
]